

import 'package:example/cannon_physics/app_demo.dart';
import 'package:example/demo/page_animation_test.dart';
import 'package:example/demo/page_ball.dart';
import 'package:example/demo/page_light_sweep.dart';
import 'package:example/demo/page_list_view.dart';
import 'package:example/demo/page_nine_patch_custom.dart';
import 'package:example/demo/page_one.dart';
import 'package:example/demo/page_video_compress3.dart';
import 'package:example/demo/test_page_view_model.dart';
import 'package:example/flame_game/drag_events_game.dart';
import 'package:example/flame_game/ember/ember_quest.dart';
import 'package:example/flame_game/ember/game_main.dart';
import 'package:example/flame_game/game_demo_1.dart';
import 'package:example/flame_game/klondike/klondike_game.dart';
import 'package:example/flame_game/pad_racing/padracing_widget.dart';
import 'package:example/flame_game/space_shooter_game.dart';
import 'package:example/flame_game/tap_events_game.dart';
import 'package:flame/game.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_base_app/base/base_page.dart';
import 'package:flutter_base_app/base/system_ui_styles.dart';

class TestPage extends StatefulWidget {
  const TestPage({super.key});

  @override
  State<TestPage> createState() => _TestPageState();
}

class _TestPageState extends BasePageState<TestPageViewModel, TestPage> {

  List<SystemUiOverlayStyle> uiOverlay = [
    systemUIDarkLight,
    systemUILightDark,
  ];

  @override
  TestPageViewModel createViewModel() {
    return TestPageViewModel();
  }

  @override
  Widget buildContent(BuildContext context) {
    return Container(
      color: Colors.amber,
      child: ListView(
        padding: EdgeInsets.zero,
        children: [
          buildItem("PageAnimationTest", const PageAnimationTest() , index: 0),
          buildItem("Cannon_physics_demo", const AppDemo() , index: 0),
          buildItem("PadracingGame", const PadracingWidget() , index: 0),
          buildItem("EmberQuestGame", const EmberQuestGameMain() , index: 0),
          buildItem("KlondikeGame", GameWidget(game: KlondikeGame()) , index: 0),
          buildItem("SpaceShooterGame", GameWidget(game: SpaceShooterGame()) , index: 0),
          buildItem("DragEventsGame", GameWidget(game: DragEventsGame()) , index: 0),
          buildItem("TapEventsGame", GameWidget(game: TapEventsGame()) , index: 0),
          buildItem("game1", const GameDemo1(), index: 0),
          buildItem("PageListView", const PageListView(), index: 0),
          buildItem("点9 canvas", const PageNinePatchCustom(), index: 0),
          buildItem("视频压缩 plugin", const PageVideoCompress3(), index: 0),
          // buildItem("视频压缩2", const PageVideoCompress2(), index: 0),
          // buildItem("视频压缩", const PageVideoCompress(), index: 0),
          buildItem("page_one", const PageOne(), index: 0),
          buildItem("重力小球", const BallPage(), index: 1),
          buildItem("文字扫光", const PageLightSweep(), index: 2),
        ],
      ),
    );
  }

  Widget buildItem(String text, Widget page, {int index = 0}){
    Color bg = uiOverlay[index % 2] == systemUIDarkLight ? Colors.white : Colors.black;
    Color textColor = uiOverlay[index % 2] == systemUIDarkLight ? Colors.black : Colors.white;
    return GestureDetector(
      onTap: (){
        Navigator.of(context).push(MaterialPageRoute(builder: (context){
          return page;
        }));
      },
      child: AnnotatedRegion<SystemUiOverlayStyle>(
        value: uiOverlay[index % 2],
        sized: true,
        child: Container(
          height: 100,
          color: bg,
          alignment: Alignment.center,
          margin: const EdgeInsets.only(top: 2),
          child: Text(text ,style: TextStyle(color: textColor),),
        ),
      ),
    );
  }

}
